package com.ewhale.feitengguest.ui.shop.mine.adapter

import android.view.View
import androidx.recyclerview.widget.RecyclerView
import com.ewhale.feitengguest.R
import com.ewhale.feitengguest.databinding.ItemShopBillBinding
import com.ewhale.feitengguest.dto.ShopBillDto
import com.simga.library.adapter.BindRecycAdapter
import java.math.BigDecimal

class ShopBillAdapter : BindRecycAdapter<ItemShopBillBinding, ShopBillDto>() {
    override fun normalViewId(): Int {
        return R.layout.item_shop_bill
    }

    override fun onBindViewHolder(mBinding: ItemShopBillBinding, itemData: ShopBillDto, holder: RecyclerView.ViewHolder, position: Int) {
        mBinding.itemData = itemData
        mBinding.tvPrice.apply {
            text = if (itemData.amount > BigDecimal(0)) {
                "+" + itemData.amount
            }else{
                itemData.amount.toString()
            }
        }
        mBinding.tvTitle.apply {
            when (itemData.type) {
                1 -> text = "充值"
                2 -> text = "提现"
                3 -> text = "发布项目"
                4 -> text = "退款"
                5 -> text = "任务更改"
                6 -> text = "提现退款"
            }
        }
        mBinding.tvStatus.apply {
            when (itemData.type) {
                2 -> {
                    visibility = View.VISIBLE
                    when (itemData.withdrawalStatus) {
                        0 -> text = "提现处理中"
                        1 -> visibility = View.GONE
                        2 -> text = "提现失败"
                    }
                }
                else -> {
                    visibility = View.GONE
                }
            }
        }
    }
}
